import request from "@/utils/request";
import { apiVersion } from "@/config";

// 全部列表
export function getAllGameExperiments(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/all`,
		method: "get",
		data,
	});
}
export function getGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment`,
		method: "get",
		data,
	});
}

/**
 * 获取非停止状态的列表
 * @param {} data
 */
export function getGameExperimentMonitor(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/monitor`,
		method: "get",
		data,
	});
}
/**
 * 添加
 * @param {} data
 */
export function addGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment`,
		method: "post",
		data: data,
	});
}
/**
 * 添加
 * @param {} data
 */
export function execCommandExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/execCommand`,
		method: "post",
		data: data,
	});
}
/**
 * 删除
 * @param {} data
 */
export function delGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}`,
		method: "delete",
		data,
	});
}
/**
 * 启动
 * @param {} data
 */
export function startGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}/start`,
		method: "put",
		data,
	});
}
/**
 * 停止
 * @param {} data
 */
export function stopGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}/stop`,
		method: "put",
		data,
	});
}
/**
 * 更新
 * @param {} data
 */
export function putGameExperiment(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment`,
		method: "put",
		data: data,
	});
}
/**
 * 取得详情
 * @param {*} data
 */
export function getGameExperimentDetail(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}`,
		noLoadding: true,
		method: "get",
	});
}
/**
 * 获取podname
 * @param {*} data
 */
export function getGameExperimentPodName(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}/podName`,
		noLoadding: true,
		method: "get",
	});
}

/**
 * 获取指标或图示数据详情
 * @param {*} data
 */
export function metricData(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}/metric/data`,
		noLoadding: true,
		headers: {
			"Content-Type": "application/x-www-form-urlencoded",
		},
		method: "get",
		data,
	});
}
/**
 * 获取指标或图示名称
 * @param {*} data
 */
export function metricKeys(data) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/${data.id}/metric/keys`,
		noLoadding: true,
		headers: {
			"Content-Type": "application/x-www-form-urlencoded",
		},
		method: "get",
		data,
	});
}

/**
 * 获取强化学习下拉选项
 * @param {*} data
 */
export function getenumItemsOP() {
	return request({
		url: `/admin/${apiVersion}/preCode/enumItems`,
		noLoadding: true,
		headers: {
			"Content-Type": "application/x-www-form-urlencoded",
		},
		method: "get",
	});
}

/**
 * 强化学习模型开发运行文件(航天智能院)
 * @param {*} command
 * @param {*} game_id
 */
export function gameExperimentRunFile({ command, game_id }) {
	return request({
		url: `/admin/${apiVersion}/game/experiment/command`,
		method: "post",
		data: { command, game_id },
	});
}
